<template>
  <div class="goods">
    <goods-list-item
      @click="itemClick(item.id)"
      v-for="item in goods"
      :product="item"
      :key="item"
    ></goods-list-item>
  </div>
</template>

<script>
import GoodsListItem from "components/content/Goods/GoodsListItem.vue";
import { useRouter } from "vue-router";
export default {
  //接收数据
  props: {
    goods: {
      type: Array,
      default() {
        return [];
      },
    },
  },
  components: {
    //商品item
    GoodsListItem,
  },
  setup() {
    const router = useRouter();
    return {
      itemClick: (id) => {
        router.push({ path: "/detail", query: { id: id } });
      },
    };
  },
};
</script>
 
<style lang="scss" scoped>
.goods {
  display: flex;
  flex-wrap: wrap;
  padding: 5px;
  justify-content: space-around;
}
</style>
